import request from '@/utils/request';



export const usrLogin = (data: User): Promise<CommonResult<User>> => {
    return request({
        url: '/user/login',
        method: 'post',
        data: data
    })
}

export const usrSetState = (data: UserState): Promise<any> => {
    return request({
        url: '/user/setState',
        method: 'put',
        data: data
    })
}


export const getEvelAndCountLevel = (): Promise<CommonResult<any>> => {
    return request({
        url: '/user/getLevel',
        method: 'get',
    })
}


export const noteDelete = (data: any): Promise<any> => {
    return request({
        url: '/note/delete',
        method: 'post',
        data: data
    })
}

export const updateUserAvatar = (data: any): Promise<CommonResult<any>> => {
    return request({
        url: '/user/update_avatar',
        method: 'post',
        data: data
    })
}

export const usrRegister = (data: User): Promise<CommonResult<User>> => {
    return request({
        url: '/user/register',
        method: 'post',
        data: data
    })
}


export const usrUpdateNote = (data: any): Promise<any> => {
    return request({
        url: '/note/upldate_note',
        method: 'put',
        data: data
    })
}

export const setIsPublic = (data: any): Promise<any> => {
    return request({
        url: '/note/setIsPublic',
        method: 'put',
        data: data
    })
}

export const createBasicFrom = (data: User): Promise<CommonResult<any>> => {
    return request({
        url: '/note/create',
        method: 'post',
        data: data
    })
}

export const findUserCommentContent = (data: any): Promise<any> => {
    return request({
        url: '/comment/findComment',
        method: 'post',
        data
    })
}

export const sendComment = (data: any): Promise<any> => {
    return request({
        url: '/comment/sendComment',
        method: 'post',
        data
    })
}


export const getNoteFormList = (params: any): Promise<CommonResult<NoteFormModel>> => {
    return request({
        url: '/note/list',
        method: 'get',
        params,
    })
}

export const testRolesApi = (): Promise<CommonResult<any>> => {
    return request({
        url: '/user/profile',
        method: 'get',
    })
}

export const findNote = (params:any): Promise<any> => {
    return request({
        url: '/note/getNode',
        method: 'get',
        params
    })
}

export const browseUpdate = (data: any): Promise<CommonResult<NoteFormModel>> => {
    return request({
        url: '/note/upldate_see',
        method: 'put',
        data
    })
}

export const likeUpdate = (data: any): Promise<CommonResult<NoteFormModel>> => {
    return request({
        url: '/note/upldate_like',
        method: 'put',
        data
    })
}

// application/x-www-form-urlencoded;charset=UTF-8;
export const uploadImages = (data: any): Promise<any> => {
    return request({
        url: '/upload/file',
        method: 'post',
        headers: {
            'Content-Type': 'multipart/form-data'
        },
        data
    })
}


export const createTask = (data: any): Promise<any> => {
    return request({
        url: '/task/createTask',
        method: 'post',
        data
    })
}

export const taskList = (): Promise<CommonResult<Task[]>> => {
    return request({
        url: '/task/list',
        method: 'get',
    })
}

export const deleteTask = (data: any): Promise<CommonResult<any>> => {
    return request({
        url: '/task/delete',
        method: 'post',
        data
    })
}

export const removeUserTask = (data: any): Promise<CommonResult<any>> => {
    return request({
        url: '/task/removeTask',
        method: 'post',
        data
    })
}

export const startUserTask = (data: any): Promise<CommonResult<any>> => {
    return request({
        url: '/task/startTask',
        method: 'post',
        data
    })
}


export const setUserTaskState = (data: any): Promise<CommonResult<any>> => {
    return request({
        url: '/task/userTaskState',
        method: 'put',
        data
    })
}


export const obtainEmails = (params: any): Promise<CommonResult<any[]>> => {
    return request({
        url: '/user/get_email',
        method: 'get',
        params,
    })
}


export const obtainWeibo = (): Promise<any> => {
    return request({
        url: '/note/weibo',
        method: 'get',
    })
    
}